cmake_minimum_required(VERSION 2.8)
project(zlib)
file(GLOB lib_srcs *.c minizip/*.c)
file(GLOB lib_hdrs z*.h)
file(GLOB minizip_hdrs minizip/*.h)
set(CMAKE_DEBUG_POSTFIX "D")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if(MSVC)
  list(APPEND lib_srcs zlib.rc zlibvc.def)
endif()
add_library(${PROJECT_NAME} SHARED ${lib_srcs} ${lib_hdrs})
install(FILES ${lib_hdrs} DESTINATION include)
install(FILES ${minizip_hdrs} DESTINATION include/minizip)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_srcs} ${lib_hdrs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
